home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 9 / Night Owl CD-ROM (NOPV9) (Night Owl Publisher) (1993).ISO / 050a / tsemac.zip / SHIFT.S < prev   
Text File  |  1993-04-13  |  4KB  |  149 lines

  1. /***********************************************************************
  2.   Author:  SemWare (Sammy Mitchell)
  3.            Additional help and input from Gary Weinfurther, Bradley Small
  4.  
  5.   Date:    April 5, 1993    Initial version
  6.            April 9, 1993    Add Copy/Cut/Paste per Gary Weinfurther
  7.  
  8.   Description:
  9.  
  10.   CUA style shift-cursor block marking/manipulation macro for TSE.  Tested
  11.   with TSE 1.0.  To work properly, you _must_ have EquateEnhancedKbd ON!!!
  12.   (This is the factory default)
  13.  
  14.   This macro will allow the dedicated (or 'grey' in TSE terms) cursor keypad
  15.   keys to be used to block a character block when shift is pressed in
  16.   combination with them, as in the Borland IDE, the MS-DOS editor, and many
  17.   Windows applications.
  18.  
  19.   In addition, the following CUA compliant keys have been assigned:
  20.  
  21.   shift ins - Paste
  22.   ctrl ins  - Copy
  23.   ctrl del  - DelBlock
  24.   shift del - Cut
  25.  
  26.   Usage notes:
  27.  
  28.   To work properly, you _must_ have EquateEnhancedKbd ON!!!  (This is the
  29.   factory default)
  30.  
  31.   To use, add these macros to your TSE.S file, and key assignments to
  32.   your TSE.KEY file, and re-bind the editor using the -b switch of sc.
  33.  
  34.   Alternatively, add the key assignments to this file, and load the
  35.   macro (as an external macro) as needed via the LoadMacro command
  36.   (<ctrl f10><L> or 'menu->macro->load')
  37.  
  38. ------------------------------------------------------------------------
  39.  
  40.    binary file (referenced below) is: (can be built using debug)
  41.  
  42.     mov     ah, 2
  43.     int     16h
  44.     mov     ah, 0
  45.     cwd
  46.     retf
  47.  
  48.     Note that this file is only needed at compile time, not at actual
  49.     macro run time.
  50.  ***********************************************************************/
  51.  
  52.  // return the keyboard flags (shift, ctrl, alt, etc)
  53. binary ["getshift.bin"]
  54.     integer proc GetShiftState() : 0
  55. end
  56.  
  57. // return FALSE if no shift keys pressed; non-zero otherwise.
  58. integer proc ShiftKeyPressed()
  59.     return (GetShiftState() & 3)
  60. end
  61.  
  62. // do the default action for the passed key; return FALSE if the key is
  63. // not recognized.
  64. integer proc DoCursorCommand(integer key)
  65.     case key
  66.         when <CursorRight>, <GreyCursorRight>
  67.             Right()
  68.         when <CursorLeft>,  <GreyCursorLeft>
  69.             Left()
  70.         when <CursorUp>,    <GreyCursorUp>
  71.             Up()
  72.         when <CursorDown>,  <GreyCursorDown>
  73.             Down()
  74.         when <Home>,        <GreyHome>
  75.             BegLine()
  76.         when <End>,         <GreyEnd>
  77.             EndLine()
  78.         when <PgUp>,        <GreyPgUp>
  79.             PageUp()
  80.         when <PgDn>,        <GreyPgDn>
  81.             PageDown()
  82.         otherwise
  83.             return (FALSE)
  84.     endcase
  85.     return (TRUE)
  86. end
  87.  
  88. // Do CUA style marking for dedicated keypad cursor keys.  If the shift
  89. // key is not pressed, do the normal cursor movement.
  90. proc CUACursorKeys()
  91.     if not ShiftKeyPressed()
  92.         DoCursorCommand(Query(key))
  93.         return ()
  94.     endif
  95.     UnmarkBlock()
  96.     MarkChar()
  97.     DoCursorCommand(Query(key))
  98.     UpdateDisplay()
  99.     While ShiftKeyPressed()
  100.         if KeyPressed()
  101.             if DoCursorCommand(GetKey())
  102.                 UpdateDisplay()
  103.             else
  104.                 PushKey(Query(key))
  105.                 break
  106.             endif
  107.         endif
  108.     endwhile
  109.     Set(Marking, off)
  110. end
  111.  
  112. // Handles the DEL key, both shift and unshifted
  113. proc mDelete()
  114.     if ShiftKeyPressed()
  115.         Cut()
  116.     else
  117.         if CurrChar() >= 0
  118.             DelChar()
  119.         else
  120.             JoinLine()
  121.         endif
  122.     endif
  123. end
  124.  
  125. // Handles the INS key, both shifted and unshifted
  126. proc mInsert()
  127.     if ShiftKeyPressed()
  128.         Paste()
  129.     else
  130.         ToggleInsert()
  131.     endif
  132. end
  133.  
  134. // key definitions
  135.  
  136. <Ins>         mInsert()
  137. <Ctrl Ins>    Copy()
  138. <Del>         mDelete()
  139. <Ctrl Del>    DelBlock()
  140.  
  141. <CursorRight> CUACursorKeys()
  142. <CursorLeft>  CUACursorKeys()
  143. <CursorUp>    CUACursorKeys()
  144. <CursorDown>  CUACursorKeys()
  145. <Home>        CUACursorKeys()
  146. <End>         CUACursorKeys()
  147. <PgUp>        CUACursorKeys()
  148. <PgDn>        CUACursorKeys()
  149.